using System;
using System.Globalization;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Xml;
using System.Reflection;
using Services;
using Utilities.Menu.UIElements;
using BowMaster.Resources;
using Services.Menu;

namespace BowMaster.SceneElements
{
    public class Arrow
    {
        //public Vector2 prevPosition;
        public Vector2 position;
        public Vector2 velocity;
        //public Vector2 prevVelocity;
        //public bool enabled;
        public Vector2 point;
        public Texture2D texture;
        public Arrow(Texture2D texture, Vector2 position, Vector2 velocity)
        {
            this.velocity = velocity;
            this.position = position;
            this.point = position;
            this.texture = texture;
            //enabled = true;
            //this.prevVelocity = position;
        }

        public void Draw(SpriteBatch spriteBatch, Matrix view, Matrix projection)
        {
            var d = velocity + position;
            var r = -(float)(Math.Atan2((float)(d.X - position.X), (float)(d.Y - position.Y)));
            r += MathHelper.ToRadians(90);
            spriteBatch.DrawTexture(texture, new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height), Color.White,
                                r, new Vector2(texture.Bounds.Width, 0) * 0.5f, view, projection);
        }
        //public void Disable()
        //{
        //    this.enabled = false;
        //    prevVelocity = velocity;
        //}
            
        
    }
}
